/* Base styles */
:root {
    --color-blue-500: #3b82f6;
    --color-slate-50: #f8fafc;
    --color-slate-100: #f1f5f9;
    --color-slate-200: #e2e8f0;
    --color-slate-300: #cbd5e1;
    --color-slate-400: #94a3b8;
    --color-slate-500: #64748b;
    --color-slate-600: #475569;
    --color-slate-700: #334155;
    --color-slate-800: #1e293b;
    --color-slate-900: #0f172a;
    --color-white: #ffffff;
    --color-red-500: #ef4444;
    --color-green-500: #10b981;
    --color-amber-500: #f59e0b;
    --color-violet-500: #8b5cf6;
    --color-indigo-500: #6366f1;
    --color-pink-500: #ec4899;
    --color-teal-500: #14b8a6;
    --color-orange-500: #f97316;
    --color-sky-500: #0ea5e9;
}

/* Light theme variables */
:root {
    --bg-color: var(--color-white);
    --text-color: var(--color-slate-900);
    --border-color: var(--color-slate-200);
    --hover-bg-color: var(--color-slate-100);
    --card-bg-color: var(--color-white);
    --modal-bg-color: var(--color-white);
    --spinner-border-color: rgba(203, 213, 225, 0.1);
    --spinner-border-top-color: var(--color-blue-500);
}

/* Dark theme variables */
.dark {
    --bg-color: var(--color-slate-900);
    --text-color: var(--color-slate-100);
    --border-color: var(--color-slate-700);
    --hover-bg-color: var(--color-slate-700);
    --card-bg-color: rgba(30, 41, 59, 0.3); /* slate-800 with opacity */
    --modal-bg-color: var(--color-slate-800);
    --spinner-border-color: rgba(255, 255, 255, 0.1);
    --spinner-border-top-color: var(--color-blue-500);
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    background-color: var(--bg-color);
    color: var(--text-color);
    width: 360px;
    height: 500px;
    overflow-x: hidden;
    transition: color 0.15s ease-out, background-color 0.15s ease-out;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-color);
}

.title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo {
    width: 24px;
    height: 24px;
    color: var(--color-blue-500);
}

.title h1 {
    font-size: 18px;
    font-weight: bold;
    color: var(--text-color);
}

.controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Theme toggle */
#theme-toggle {
    display: inline-grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    background-color: rgba(15, 23, 42, 0.05);
    padding: 3px;
    border-radius: 9999px;
    color: var(--color-slate-900);
}

.dark #theme-toggle {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--color-white);
}

#theme-toggle span {
    border-radius: 9999px;
    padding: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#theme-toggle span:hover {
    background-color: rgba(203, 213, 225, 0.5);
}

.dark #theme-toggle span:hover {
    background-color: rgba(51, 65, 85, 0.5);
}

#theme-toggle span svg {
    width: 16px;
    height: 16px;
}

#theme-toggle [data-checked] {
    background-color: var(--color-white);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.1);
}

.dark #theme-toggle [data-checked] {
    background-color: var(--color-slate-700);
    color: var(--color-white);
    box-shadow: none;
}

/* Help button */
.help-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 9999px;
    background-color: var(--color-slate-100);
    color: var(--color-slate-600);
    border: none;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.dark .help-button {
    background-color: var(--color-slate-700);
    color: var(--color-slate-300);
}

.help-button:hover {
    background-color: var(--color-slate-200);
    color: var(--color-slate-800);
}

.dark .help-button:hover {
    background-color: var(--color-slate-600);
    color: var(--color-white);
}

/* Main content */
main {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background-color: var(--color-slate-50);
}

.dark main {
    background-color: var(--color-slate-900);
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.main-header h2 {
    font-size: 18px;
    font-weight: bold;
    color: var(--text-color);
}

/* Refresh control */
.refresh-control {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.refresh-control:hover {
    background-color: rgba(100, 116, 139, 0.1);
}

.dark .refresh-control:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.refresh-control.active {
    color: var(--color-blue-500);
}

.refresh-control.paused {
    color: var(--color-slate-500);
}

.dark .refresh-control.paused {
    color: var(--color-slate-400);
}

/* States */
.state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px 0;
}

.state-container p {
    color: var(--color-slate-600);
    margin-top: 8px;
}

.dark .state-container p {
    color: var(--color-slate-400);
}

.state-container h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-slate-700);
    margin-bottom: 8px;
}

.dark .state-container h3 {
    color: var(--color-slate-300);
}

.help-button-large {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 6px;
    background-color: var(--color-blue-500);
    color: var(--color-white);
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 16px;
}

.help-button-large:hover {
    background-color: #2563eb; /* blue-600 */
}

/* Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--spinner-border-color);
    border-top: 3px solid var(--spinner-border-top-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Hosts container */
#hosts-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.host-group {
    background-color: var(--card-bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.group-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-color);
}

.host-list {
    list-style: none;
    border-top: 1px solid var(--border-color);
}

.host-item {
    transition: background-color 0.2s;
}

.host-item:hover {
    background-color: var(--hover-bg-color);
}

.host-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--text-color);
}

.host-content {
    display: flex;
    align-items: center;
    flex: 1;
}

.host-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Service icons */
.icon-service {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    margin-right: 8px;
    font-size: 8px;
    font-weight: bold;
    color: white;
}

.icon-api { background-color: var(--color-blue-500); }
.icon-api:after { content: "API"; }

.icon-fe { background-color: var(--color-green-500); }
.icon-fe:after { content: "FE"; }

.icon-cdn { background-color: var(--color-amber-500); }
.icon-cdn:after { content: "CDN"; }

.icon-docs { background-color: var(--color-violet-500); }
.icon-docs:after { content: "DOC"; }

.icon-admin { background-color: var(--color-red-500); }
.icon-admin:after { content: "IS"; }

.icon-mailpit { background-color: var(--color-indigo-500); }
.icon-mailpit:after { content: "MAIL"; }

.icon-npm { background-color: var(--color-pink-500); }
.icon-npm:after { content: "NPM"; }

.icon-producer { background-color: var(--color-teal-500); }
.icon-producer:after { content: "PROD"; }

.icon-rabbitmq { background-color: var(--color-orange-500); }
.icon-rabbitmq:after { content: "RMQ"; }

.icon-kafka { background-color: var(--color-sky-500); }
.icon-kafka:after { content: "KFK"; }

.icon-default { background-color: var(--color-slate-500); }
.icon-default:after { content: "SVC"; }

/* Icons */
.icon-help:after {
    content: "?";
    font-weight: bold;
    display: inline-block;
    width: 1em;
    text-align: center;
}

.icon-settings:after {
    content: "⚙";
    font-weight: bold;
    display: inline-block;
    width: 1em;
    text-align: center;
}

.icon-sync:after {
    content: "↻";
}

.icon-pause:after {
    content: "⏸";
}

.icon-expand:after {
    content: "▼";
    display: inline-block;
    transition: transform 0.2s;
    transform: rotate(0deg);
}

.icon-arrow:after {
    content: "→";
}

.icon-public-off:after {
    content: "⊗";
    font-size: 24px;
    display: block;
    margin-bottom: 8px;
    color: var(--color-slate-400);
}

.dark .icon-public-off:after {
    color: var(--color-slate-500);
}

/* Collapsible sections */
.collapsed .host-list {
    display: none;
}

.collapsed .icon-expand:after {
    transform: rotate(-90deg);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--modal-bg-color);
    border-radius: 8px;
    width: 90%;
    max-height: 90%;
    overflow-y: auto;
    transform: translateY(20px);
    transition: transform 0.3s;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.dark .modal-content {
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.modal-body {
    padding: 16px;
}

.modal-body h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-slate-700);
    margin: 16px 0 8px;
}

.dark .modal-body h4 {
    color: var(--color-slate-300);
}

.modal-body h4:first-child {
    margin-top: 0;
}

.modal-body p {
    font-size: 13px;
    line-height: 1.5;
    color: var(--color-slate-600);
    margin-bottom: 8px;
}

.dark .modal-body p {
    color: var(--color-slate-400);
}

.modal-body code {
    background-color: var(--color-slate-100);
    color: var(--color-slate-700);
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 12px;
}

.dark .modal-body code {
    background-color: var(--color-slate-700);
    color: var(--color-slate-300);
}

.modal-body pre {
    background-color: var(--color-slate-100);
    color: var(--color-slate-700);
    padding: 12px;
    border-radius: 6px;
    font-size: 12px;
    overflow-x: auto;
    margin: 8px 0 16px;
}

.dark .modal-body pre {
    background-color: var(--color-slate-900);
    color: var(--color-slate-300);
}

.close-modal {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--color-slate-500);
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--color-slate-900);
}

.dark .close-modal:hover {
    color: var(--color-white);
}

/* Form styles */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 13px;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-blue-500);
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.btn-primary {
    padding: 8px 16px;
    background-color: var(--color-blue-500);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #2563eb; /* blue-600 */
}

.btn-secondary {
    padding: 8px 16px;
    background-color: var(--color-slate-200);
    color: var(--color-slate-700);
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.dark .btn-secondary {
    background-color: var(--color-slate-700);
    color: var(--color-slate-300);
}

.btn-secondary:hover {
    background-color: var(--color-slate-300);
}

.dark .btn-secondary:hover {
    background-color: var(--color-slate-600);
}

/* Utility classes */
.hidden {
    display: none !important;
}
